<template>
  <div class="newsCenter">
    <Header @modify="modify" @naviBack="naviBack" :title="title" :flag="flag" :title2="title2"></Header>
    <div class="inputDiv">
      <input type="text" name="name" v-model="text">
      <input type="hidden" name="type" value="1">
    </div>
    <div class="tips" v-if="tips">
      <span>{{tipsHtml}}</span>
    </div>
  </div>
</template>
<script>
  import Header from './userheader.vue'
  export default({
    data (){
      return {
        title:'修改信息',
        flag:false,
        title2:'保存',
        text:'',
        tips:false
      }
    },
    methods:{
      naviBack(){
        this.$router.go(-1)
      },
      modify (){
          let that =this
        this.axios.post('/home/User/editUserInfo',{
          uid:this.uid||localStorage.getItem('uid'),
          nickname:this.text,
          type:1
        })
          .then((res)=>{
           console.log(res.data)
            if(res.data.code==1){
              this.$router.push({
                name:'editorUser'
              })
            }else{
              this.tips =true
              this.tipsHtml =res.data.msg
              setTimeout(function () {
                that.tips =false
              },300)
            }
          }).catch((res)=>{
          console.log(res.error)
        })
//
      },
    },
    components:{
      Header
    },
    mounted () {
      this.text =this.$route.query.item
    }
  })
</script>
<style scoped>
  .newsCenter >>> .newsheader .ico2{
    font-size: 0.32rem;
  }
  .newsCenter {
    background: #f6f6f6;
    height: 100%;
  }
  .newsCenter .newsheader .ico-bc{
    font-size: 0.32rem;
  }
  .inputDiv{
    line-height: 0.68rem;
    font-size: 0.28rem;
    color: #333;
    margin: 0 0.32rem;
    margin-top: 0.3rem;
    border-bottom: 0.02rem solid #ccc;
  }
  .inputDiv input{
    display: inline-block;
    width: 100%;
    height: 0.68rem;
    border: none;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    background: #f6f6f6;
  }
  .tips{
    position:fixed;
    left:50%;
    top:50%;
    padding: 0 0.3rem;
    min-width:2rem;
    max-width:80%;
    text-align:center;
    font-size:.28rem;
    color:#fff;
    background:rgba(0,0,0,.8);
    border-radius:.1rem;
    -webkit-transition:all .25s ease 0s;
    transition:all .25s ease 0s;
    -webkit-transform:translate(-50%,-50%);
    -ms-transform:translate(-50%,-50%);
    transform:translate(-50%,-50%);
    height: 0.8rem;
    line-height: 0.8rem;
  }
</style>
